package freespiritsocial.io.user.ui.adapter

import com.bumptech.glide.load.resource.bitmap.CenterInside
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder
import com.scwang.smart.refresh.layout.util.SmartUtil.dp2px
import freespiritsocial.io.user.R
import freespiritsocial.io.user.databinding.ItemPostIamgesBinding
import freespiritsocial.io.user.ext.loadImageWithTopCorner
import freespiritsocial.io.user.ext.setAdapterAnimation

/**
 * 图片适配器
 */
class PostImagesAdapter(
    data: MutableList<String>? = mutableListOf(),
    val corner: Int = 0,
    layoutResIdRes: Int = R.layout.item_post_iamges
):
    BaseQuickAdapter<String,BaseDataBindingHolder<ItemPostIamgesBinding>>(layoutResIdRes,data) {
    init {
        setAdapterAnimation(0)
    }

    override fun convert(holder: BaseDataBindingHolder<ItemPostIamgesBinding>,item: String) = with(holder.dataBinding) {
        this?.image?.loadImageWithTopCorner(item,0,transformation = CenterInside())
        Unit
    }
}